﻿using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

using Mang24k99.Model.Dissertation;
using Mang24k99.Business.Dissertation;
using System.Text;

namespace Mang24k99.Web.Dissertation
{
    /// <summary>
    /// Summary description for $codebehindclassname$
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class Dissertation : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string param = context.Request.Params["param"].ToString();
            context.Response.StatusCode = 200;
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);

            StringBuilder returnValue = new StringBuilder();
            returnValue.Append("<table id=\"searchTable\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align=\"center\" bordercolor=\"#BED6A6\" style=\"border-collapse: collapse;background-color:#fff;\">");
            returnValue.Append("");

            MColumnsTable[] columns = BColumnsTable.Search(param.ToLower());
            if (columns != null)
            {
                int index = 1;
                foreach (MColumnsTable aColumn in columns)
                {
                    returnValue.Append("<tr>");
                    returnValue.Append("<td class=\"tb_txt2\" nowrap=\"nowrap\" style=\"cursor:pointer;\" name=\"columnName\" onclick=\"selectColumn('" + aColumn.ColumnID + "','" + aColumn.ColumnName + "')\">");
                    returnValue.Append("" + aColumn.ColumnName + "</td>");
                    returnValue.Append("</tr>");
                    if (index++ > 4)
                        break;
                }
            }
            returnValue.Append("</table>");

            //returnValue = "this is a testing!";
            context.Response.Write(returnValue.ToString());
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
